const APIBASE_URL = 'https://api-ivm.myhuaweicloud.com/v1/114527713920221206095540'
// 119.3.177.108:7050
// const APIBASE_URL = 'https://119.3.177.108:7050'
export const getAccessToken = () => {
	return new Promise((resolve, reject) => {
		uni.request({
			url: APIBASE_URL + '/enterprises/access-token',
			method: 'POST',
			data: {
				ak: "630d0a664ac4395bf4d06c19854f4a19",
				sk: "ec3c68f13452f8c7e793185ebfcde90b3ec874a8007844073d9c61a5363fdfdd"
			},
			success: (res) => {
				resolve(res)
			},
			//请求失败
			fail: (err) => {
				uni.showToast({
					title: '请求接口失败'
				})
				reject(err)
			}
		})
	})
}

// 获取设备信息
export const getDeviceInfo = (token, deviceId) => {
	return new Promise((resolve, reject) => {
		uni.request({
			url: APIBASE_URL +
				`/devices/${deviceId}`,
			method: 'GET',
			header: {
				"Access-Token": token
			},
			success: (res) => {
				resolve(res)
				uni.showToast({
					title: '获取状态成功'
				})
			},
			//请求失败
			fail: (err) => {
				uni.showToast({
					title: '请求接口失败',
					icon: 'none'
				})
				reject(err)
			}
		})
	})
}
